package lesson15;

import lesson14.Person;

public class Car {

	String model;
	double maxSpeed;
	int currentSpeed;
	String color;
	int gear;
	Person owner;
	double price;
	boolean isSportCar;
	
	void accelerate(int acceleration)
	{
		if (currentSpeed >= maxSpeed)
		{
		//	currentSpeed = maxSpeed;
			System.out.println("Max speed reached!");
		}
		currentSpeed+=acceleration;
	}
	
	void changeGearUp() 
	{
		gear++;
	}
	
	void chnageGearDown()
	{
		gear--;
	}
	
	void changeGear(int nextGear)
	{
		gear = nextGear;
	}
	
	void changeColor(String newColor)
	{
		color = newColor;
	}
	
	
	Car(String model, boolean isSportCar, String color)
	{
		this.model = model;
		this.isSportCar = isSportCar;
		this.color = color;
		
		
	}
	
	Car(String model, boolean isSportCar, String color, double price, double maxSpeed)
	{
		this(model, isSportCar, color);
		this.price = price;
		if (maxSpeed > 200 && isSportCar)
		{
			this.maxSpeed = maxSpeed;
		}else{
			this.maxSpeed = 150;
		}
	}
	
	boolean isMoreExpensive(Car car){
		
		return this.price > car.price;
		
	}
	
	double calculateCarPriceForScrap(double metalPrice)
	{
		
		double coef = 0.2;
		if (this.color.equalsIgnoreCase("white") || this.color.equalsIgnoreCase("black"))
		{
			coef += 0.05;
		}
		if (isSportCar)
		{
			coef += 0.05;
		}
		
		metalPrice = metalPrice*coef;
		
		return metalPrice;
	}
	
	
}
